package com.guodi.map.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guodi.map.config.HideLayerServiceConfig;
import com.guodi.map.entity.MapDataSource;
import com.guodi.map.mapper.MapDataSourceMapper;
import com.guodi.map.service.IMapDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @描述：地图数据源表 服务类
 * @作者: 代鹏刚
 * @日期: 2019-12-20
 */
@Service
public class MapDataSourceServiceImpl extends ServiceImpl<MapDataSourceMapper, MapDataSource> implements IMapDataSourceService {
    @Autowired
    private HideLayerServiceConfig hideLayers;

    /**
    * @描述: 根据服务地址判断该服务类型是否隐藏图层
    * @入参:
    * @出参:
    * @作者: 代鹏刚
    * @日期: 2022/4/28 17:54
    **/
    @Override
    public boolean showLayerFlag(String serverUrl, boolean tileFlag) {
        final String mapServer="MapServer";
        boolean showLayerFlag=true;
        String serviceTypes = serverUrl.substring(serverUrl.lastIndexOf("/")+1);
        serverUrl.indexOf(mapServer);
        if((hideLayers.getServiceType()!=null&&hideLayers.getServiceType().contains(serviceTypes))){
            showLayerFlag=false;
        }
        //地图切片服务
        if(mapServer.equals(serviceTypes)&&tileFlag){
            showLayerFlag=false;
        }
        return showLayerFlag;
    }
}
